function isNotEmpty(s) {
    return s != null && s.trim().length > 0;
}

function isEmpty(s) {
    return !isNotEmpty(s);
}

function isSubmitKeyCode(e) {
    return e.keyCode == 13;
}

function getAccountFromCookie() {
    return $.cookie('account');
}

function setAccountToCookie(account) {
    $.cookie('account', account);
}

String.prototype.parseDate = function (format) {
    var dateVal = this.trim();
    var dateArr = ['', '', '', '', '', '', ''];
    for (var i = 0; i < format.length; i++) {
        switch (format.charAt(i)) {
            case "y":
                dateArr[0] += dateVal.charAt(i);
                break;
            case "M":
                dateArr[1] += dateVal.charAt(i);
                break;
            case "d":
                dateArr[2] += dateVal.charAt(i);
                break;
            case "H":
                dateArr[3] += dateVal.charAt(i);
                break;
            case "m":
                dateArr[4] += dateVal.charAt(i);
                break;
            case "s":
                dateArr[5] += dateVal.charAt(i);
                break;
            case "S":
                dateArr[6] += dateVal.charAt(i);
                break;
        }
    }

    return new Date(dateArr[0] - 0, dateArr[1] - 1, dateArr[2] - 0, dateArr[3] - 0, dateArr[4] - 0, dateArr[5] - 0, dateArr[6] - 0);
};

Date.prototype.format = function (fmt) {
    var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //日
        "h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, //小时
        "H+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds(), //秒
        "S": this.getMilliseconds() //毫秒
    };
    var weeks = {
        "0": "星期一",
        "1": "星期二",
        "2": "星期三",
        "3": "星期四",
        "4": "星期五",
        "5": "星期六",
        "6": "星期日"
    };
    if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    if (/(E+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, weeks[this.getDay()]);
    }
    for (var k in o) {
        if (new RegExp("(" + k + ")").test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        }
    }
    return fmt;
};

Date.prototype.getDayBeginTime = function() {
    return this.format('yyyy-MM-dd' + ' 00:00:00.000').parseDate('yyyy-MM-dd HH:mm:ss.SSS').getTime();
};

Date.prototype.getDayEndTime = function() {
    return this.format('yyyy-MM-dd' + ' 23:59:59.999').parseDate('yyyy-MM-dd HH:mm:ss.SSS').getTime();
};

Array.prototype.removeAt = function(index) {
    if(this.length == 0 || isNaN(index) || index > this.length || index < 0) {
        return;
    }
    for(var i = index; i < this.length; i++) {
        this[i] = this[i-0+1];
    }
    this.length -= 1;
};
